package fun.ty13;

import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author 桃缘十三
 * @date 2022/11/25 15:01
 */
@SpringBootApplication
//@EnableEurekaClient //声明uereka的客户端- 可以省略
@EnableCircuitBreaker //声明熔断器
public class OrderServerApp {
    public static void main(String[] args) {
        SpringApplication.run(OrderServerApp.class);
    }
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    /**
     * 配置负载均衡策略
     * @return
     */
    @Bean
    public RandomRule getRandomRule() {
        return new RandomRule();
    }
}
